package operations;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOperation {
    public void work(BookList bookList) {
        System.out.println("归还书籍");
        System.out.print("请输入你要归还的书籍的名字：");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();

        int currentsize = bookList.getUsedsize();
        for (int i = 0; i < currentsize; i++) {
            Book book = bookList.getPos(i);
            if (name.equals(book.getName())) {
                book.setBorrowed(false);
                System.out.println("归还书籍成功");
                return;
            }
        }
    }
}
